package com.cy.mall.comm.constant;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;

import com.cy.mall.comm.properties.OssProperties;
import com.cy.mall.comm.properties.SystemProperties;
import com.cy.mall.comm.utils.SpringContextUtils;

/**
 * 
 * @description: 系统常量
 * @author: Ocean
 * @create: 2018-07-23 15:36
 **/
public class Constants {

    public static final Boolean IS_PROD;

    public static final String SLAT;

    public static final String PROFILES_ACTIVE;

    public static final String FUJUE_RSA_PUBLIC_KEY;

    public static final String FUJUE_RSA_PRIVATE_KEY;

    public static final Long XSS_PRODUCTID;
    public static final Long XXSC_PRODUCTID;
    public static final Long JYD_PRODUCTID;

    public static final String BUCKETNAME;

    public static final List<String> IMAGE_SUFFIX = new ArrayList<>();

    static {
        SystemProperties systemProperties = SpringContextUtils.getBean(SystemProperties.class);
        IS_PROD = systemProperties.getIsProd();
        SLAT = systemProperties.getSalt();
        PROFILES_ACTIVE = systemProperties.getProfilesActive();
        FUJUE_RSA_PUBLIC_KEY = systemProperties.getFujueRsaPublicKey();
        FUJUE_RSA_PRIVATE_KEY = systemProperties.getFujueRsaPrivateKey();
        XSS_PRODUCTID = Long.parseLong(systemProperties.getXssProductId());
        XXSC_PRODUCTID = Long.parseLong(systemProperties.getXxscProductId());
        JYD_PRODUCTID = Long.parseLong(systemProperties.getJydProductId());

        BUCKETNAME = SpringContextUtils.getBean(OssProperties.class).getBucketName();

        IMAGE_SUFFIX.add(".jpg");
        IMAGE_SUFFIX.add(".jpeg");
        IMAGE_SUFFIX.add(".png");
        IMAGE_SUFFIX.add(".bmp");
        IMAGE_SUFFIX.add(".gif");
    }

    public static final String ASYNC = "asyncExecutor";

    /** 7 * 24 = 168 七天 */
    public static final Integer LOGIN_TIME = 168;

    public static final TimeUnit LOGIN_TIME_UNIT = TimeUnit.HOURS;

    public static final String CUSTOMER_LOGIN_KEY = "CUSTOMER-LOGIN:";
    
    public static final String SMS_CODE = "SMS-CODE:";
    
    /** 用户初始密码：chaoyue2018 */
    public static final String INIT_PASSWORD = "chaoyue2018";

    public static final String yyyyMMddHHmmssSSS = "yyyyMMddHHmmssSSS";

    public static final String yyyy_MM_dd_HH_mm_ss = "yyyy-MM-dd HH:mm:ss";
    
    /** 上传最大文件大小   */
    public static final Long MAX_FILE_SIZE = 20 * 1024 * 1024L;  
    
    public static final Long MAX_FILE_SIZE_MB = 20L;
    
    public static final String CUSTOMER_SOURCE_BANKMA_MALL = "马先生商城";
    
}
